package com.nbsaas.boot.entity.evaluate;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.code.annotation.bean.StoreStateBean;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.jpa.data.entity.User;
import com.nbsaas.boot.rest.enums.StoreState;
import com.nbsaas.boot.rest.filter.Operator;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

/**
 * 评价点赞
 * 
 * @author 系统生成
 */
@Comment("评价点赞功能")
@FormAnnotation(title = "评价点赞管理", model = "评价点赞")
@StoreStateBean
@CreateByUser
@Data
@Entity
@Table(name = "bs_evaluate_like", 
       uniqueConstraints = @UniqueConstraint(columnNames = {"evaluate_id", "user_id"}))
public class EvaluateLike extends AbstractEntity {

    @Comment("关联评价")
    @SearchItem(label = "关联评价", name = "evaluate", key = "evaluate.id", operator = Operator.eq, classType = Long.class)
    @FormField(title = "关联评价", sortNum = "10", grid = true, required = true, type = InputType.select, option = "evaluate")
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false, name = "evaluate_id")
    private Evaluate evaluate;

    @Comment("点赞用户")
    @SearchItem(label = "点赞用户", name = "user", key = "user.id", operator = Operator.eq, classType = Long.class)
    @FormField(title = "点赞用户", sortNum = "20", grid = true, required = true, type = InputType.select, option = "user")
    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false, name = "user_id")
    private User user;

    @Comment("点赞类型")
    @SearchItem(label = "点赞类型", name = "likeType", operator = Operator.eq, classType = Integer.class, type = InputType.dictionary)
    @FormField(title = "点赞类型", sortNum = "30", grid = true, required = true, type = InputType.dictionary)
    @Dict(
            items = {
                    @DictItem(value = 1, label = "有用"),
                    @DictItem(value = 2, label = "无用"),
                    @DictItem(value = 3, label = "点赞"),
                    @DictItem(value = 4, label = "踩")
            }
    )
    @Column(nullable = false)
    private Integer likeType;

    @Comment("点赞状态")
    @SearchItem(name = "storeState", label = "状态", operator = Operator.eq, classType = StoreState.class)
    @FormField(title = "状态", sortNum = "40", grid = true, type = InputType.dictionary)
    private StoreState storeState;

    @Comment("IP地址")
    @FormField(title = "IP地址", sortNum = "50", grid = true)
    @Column(length = 50)
    private String ipAddress;

    @Comment("用户代理")
    @FormField(title = "用户代理", sortNum = "60", grid = true)
    @Column(length = 500)
    private String userAgent;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "70", grid = true, type = InputType.textarea)
    @Column(length = 200)
    private String note;
} 